package com.fs.constant;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by fengshuai on 17/6/16.
 */
public enum DbInfoEnum {
    SETTLE_MAIN_WRITE(1, 1, "【结算主库-写】"),
    SETTLE_MAIN_READ(2, 2,"【结算主库-读】"),
    SETTLEMENT_WRITE(3, 1,"【结算单库-写】"),
    SETTLEMENT_READ(4, 2,"【结算单库-读】"),
    PRICE_WRITE(5, 1,"【众包price库-写】"),
    PRICE_READ(6, 2,"【众包price库-读】"),
    SETTLE_UNIT_WRITE(7, 1,"【结算单元库-写】"),
    SETTLE_UNIT_READ(8, 2,"【结算单元库-读】"),
    FINANCE_BASE_WRITE(9, 1,"【financebase库-写】"),
    FINANCE_BASE_READ(10, 2,"【financebase库-读】");

    private int id;
    private int type;
    private String name;

    DbInfoEnum(int id, int type, String name) {
        this.id = id;
        this.type = type;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public int getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public static List<Integer> batchGetByType(int type) {
        List<Integer> list = new ArrayList<>();
        for (DbInfoEnum dbInfoEnum : values()) {
            if (type == 0 || type == dbInfoEnum.getType()) {
                list.add(dbInfoEnum.getId());
            }
        }
        return list;
    }

    public static String getNameById(int id) {
        for (DbInfoEnum dbInfoEnum : values()) {
            if (id == dbInfoEnum.getId()) {
                return dbInfoEnum.getName();
            }
        }
        return "null";
    }
}
